import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)
// 防止路由重复点击报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [{
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue')
  },
  {

    path: '/manager',
    name: 'manager',
    component: () => import('@/views/Manager.vue'),
    children: [
      // 首页
      {
        path: 'home',
        component: () => import('@/views/home/Home.vue')
      },
      //订单
      {
        path: 'order',
        component: () => import('@/views/order/Order.vue'),
      },
       //订单
       {
        path: 'order/orderDetail',
        component: () => import('@/views/order/OrderDetail.vue'),
      },

      // 我的
      {
        path: 'mine',
        component: () => import('@/views/mine/Mine.vue')
      },
    ]
  },
  {
    path: '/shop',
    component: () => import('@/views/shop/Shop.vue'),
    children: [
      {
        path: 'goods',
        component: () => import('@/views/shop/shopGoods/ShopGoods.vue'),
      },
      {
        path: 'rating',
        component: () => import('@/views/shop/shopRatings/ShopRatings.vue')
      },
      {
        path: 'shopInfo',
        component: () => import('@/views/shop/shopInfo/ShopInfo.vue')
      },
      {
        path: '/',
        redirect: 'goods'
      }
    ],
  },
  /**
   * 评价
   */
  {
    path:'/order/evaluate',
    name: 'Evaluate',
    component:() => import('@/views/evaluate/Evaluate.vue')
  },
  /**
   * 确认订单
   */
  {
    path:'/orderConfirm',
    name: 'OrderConfirm',
    component:() => import('@/views/order/OrderConfirm.vue')
  },
  {
    path:'/error',
    component:() => import('@/views/error/Error.vue')
  },
  {
    path:'/error404',
    component:() => import('@/views/error/Error404.vue')
  }
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})



export default router